import request from '@/utils/request'

export function updateRole(id, data) {
  return request({
    url: `/vue-element-admin/role/${id}`,
    method: 'put',
    data
  })
}
// 获取所有用户的相关信息
export function getRoleManage(query) {
  return request({
    url: '/role/manage',
    method: 'get',
    params: query
  })
}
// 创建新用户
export function createUser(token, data) {
  return request({
    url: '/role/create',
    method: 'post',
    params: { token },
    data
  })
}
// 获取所有用户的权限列表
export function getRoleList(token) {
  return request({
    url: '/role/list',
    method: 'get',
    params: token
  })
}
// 修改用户权限
export function modifyRole(token, data) {
  return request({
    url: '/role/update',
    method: 'post',
    params: token,
    data
  })
}
// 强制用户失效
export function offActive(query) {
  return request({
    url: '/role/off',
    method: 'get',
    params: query
  })
}
// 修改用户信息
export function modifyInfo(token, data) {
  return request({
    url: '/role/info',
    method: 'post',
    params: { token },
    data
  })
}
// 删除用户
export function deleteRole(token, data) {
  return request({
    url: '/role/delete',
    method: 'delete',
    params: { token },
    data
  })
}
// 获取权限表
export function getPermission(token) {
  return request({
    url: '/role/permission',
    method: 'get',
    params: { token }
  })
}
// 编辑权限表
export function editPermission(token, data) {
  return request({
    url: '/role/permission/edit',
    method: 'post',
    params: { token },
    data
  })
}
// 查询指定用户权限的用户有哪些
export function getUerByPermission(token, permission) {
  return request({
    url: '/role/permission/look',
    method: 'get',
    params: { token, permission }
  })
}
